<?php
namespace Home\Controller;
use Think\Controller;
use Think\Auth; 

class IndexController extends Controller {
    public function index(){
        echo "hello home";
        echo "<br>";
        echo abs(1-1);
        echo "<br>";
        echo abs(0-1);
        echo "<br>";
        echo "<a href='index.php/admin/'>Login</a>";
    }

    public function test(){
    	header("Content-type: text/html; charset=utf-8"); 
    	session('uid','1');

    	$auth = new Auth();

    	if($auth->check('Admin/Member/index,Admin/Member/show',session('uid'),1,1,'and')){  
            echo '有权限'; 
            var_dump($auth->getGroups(session('uid')));
        }else{  
            echo '没有权限';  
            //todo...  
        } 
    }

    public function getajax(){
    	if(IS_AJAX){
    		$data['status']  = 1;
			$data['content'] = '我们可以指定格式返回';
    		$this->ajaxReturn($data);
    	}else{
    		$this->error("非法请求");
    	}
    	
    }


	public function getexcel(){
		$data = array(
		array(NULL, 2010, 2011, 2012),
		array('Q1',   12,   15,   21),
		array('Q2',   56,   73,   86),
		array('Q3',   52,   61,   69),
		array('Q4',   30,   32,    0),
	   );
		create_xls($data);
	}

	public function stucel(){
		$STU=M("Student");
		$TH = M("Teacher");
		$data = $STU->order('id desc')->select();
		for ($x=0;$x<count($data);$x++){
				$datatime1 = date_create($data[$x]['birthday']);
				$datatime2 = date_create();
				$interval = date_diff($datatime1,$datatime2);
				$data[$x]['age'] = $interval->format('%y岁');
				$res = $TH->where('id='.$data[$x]['zserid'])->find();
				$data[$x]['zserid']=$res['name'];
				$data[$x]['id']=$x+1;
		}
		create_xls($data,"招生报名表.xls");
	}




}